package com.boboPlanet.dict.controller;

import com.boboPlanet.comm.result.ResponseResult;
import com.boboPlanet.dict.entity.vo.SensitiveVO;
import com.boboPlanet.dict.service.LogService;
import com.boboPlanet.dict.entity.dto.SysLogDTO;
import com.boboPlanet.dict.entity.po.SysLogPO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/2/23
 **/
@RestController
@RequestMapping("/sysLog")
@Api(tags = "日志操作", value = "日志操作")
@Slf4j
public class LogController {

    @Resource
    private LogService logService;

    @PostMapping("/addSysLog")
    @ApiOperation("插入日志记录")
    public ResponseResult<Boolean> addSysLog(@RequestBody SysLogDTO dto) {
        return ResponseResult.isSuccess(logService.addSysLog(dto));
    }

    @PostMapping("/querySysLog")
    @ApiOperation("查询日志记录")
    public ResponseResult<List<SysLogPO>> querySysLog(@RequestBody SysLogDTO dto) {
        return ResponseResult.isSuccess(logService.querySysLog(dto));
    }

    @GetMapping("/testSensitive")
    @ApiOperation("测试数据脱敏")
    public ResponseResult<SensitiveVO> testSensitive(@ApiParam("指定脱敏的关键字") String key, String replace) {
        SensitiveVO vo = new SensitiveVO();
        vo.setPhone("15648792025");
        vo.setEmail("5505148515@qq.com");
        vo.setName("mis——wu");
        return ResponseResult.isSuccess(vo);
    }

}
